package com.cc8w.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class WebLogAspect {
    private Logger logger = LoggerFactory.getLogger(WebLogAspect.class);


    /**
     * 定义切入点，切入点为com.cc8w.home.service下的所有函数
     */
    //@Pointcut("execution(public * com.cc8w.home.service..*.*(..))")
    @Pointcut("execution(public * com.cc8w.home.service.UserService.queryUserByUserName(java.lang.String))")
    public void webLog(){}
    /**
     * 前置通知：在连接点之前执行的通知
     * @param joinPoint
     * @throws Throwable
     * 注意切面表达式书写
     */

    @Before("webLog()")
    public void before(JoinPoint joinPoint) throws Throwable{
        System.out.println("before...");

    }
    @After("webLog()")
    public void after(JoinPoint joinPoint){
        System.out.println("after...");
        System.out.println(joinPoint);

    }



}
